#coding=utf-8
"""
Author:朱燕珍
Time:2025/8/28 19:38
"""
from config.config import *
import time
import unittest
from public.utiles.HTMLTestRunnerNew import HTMLTestRunner
from public.utiles.mail import SendMail

now = time.strftime('%Y-%m-%d-%H-%M-%S')
filename = report_path + "\\" +str(now) + 'ui_report.html'
def auto_run():
    discover = unittest.defaultTestLoader.discover(start_dir=testcase_path,
                                                   pattern='test_*.py')
    f = open(filename,'wb')
    runner = HTMLTestRunner(stream=f,
                            title='cms后台UI自动化测试报告',
                            description='测试用例执行如下：',
                            tester='小朱')
    runner.run(discover)
    f.close()

def sendMail():
    sm = SendMail(send_msg=filename,attachment=filename)
    sm.send_mail()
if __name__ == '__main__':
    auto_run()
    sendMail()